/* GUI CONVERTED from rcabssdl.p (converter v1.75) Tue Apr 10 12:03:14 2001 */
/* rcabssdl.p - PROGRAM TO DELETE abss_det FOR SEQUENCE SCHEDULES             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.5 $                                                         */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 9.1     CREATED:       05/24/99    BY: *N003* Patrick Rowan      */
/* REVISION: 9.1    MODIFIED:       08/12/00    BY: *N0KP* Mark Brown         */
/* $Revision: 1.5 $    BY: Jean Miller    DATE: 03/22/01 ECO: *P008*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/*!
 ----------------------------------------------------------------------------
 DESCRIPTION: This program deletes the links between the shipper records
              (abs_mstr) and the sequence details records (rcsd_det).

 Notes:
 1. This program can be called with a abs_id to delete all links attached to
    that shipper, container, item, etc. OR this program can be called with
    an abss_det record to delete a single entry.
 2. For any link that is deleted, the x-reference link is also deleted.  The
    x-reference link bridges two sequence detail records where one is shipped
    and the other is refered to the shipped sequence.  Deleting the x-referenc
    opens up a requirement to fulfill the sequence.
 3. You only need to check the *Shipped* side of the rcsx_ref.  The *Linked*
    side will not have an abss_det to delete, because there is no shipment
    on the *Linked* side.  That is the purpose of the rcsx_ref table; to
    build a link between a sequence that is shipped and one that isn't.

 ============================================================================
 !*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */

{mfdeclre.i}

define input parameter in_abs_recid as recid no-undo.
define input parameter in_abss_recid as recid no-undo.

/* INITIALIZATION */
for first abs_mstr
where recid (abs_mstr) = in_abs_recid
no-lock: end.

for first abss_det
where recid (abss_det) = in_abss_recid
no-lock: end.

if available (abss_det) then
   /* DELETE ONE abss_det */
   run delete_abss_det
     (input recid(abss_det)).

else do:

   /* DELETE ALL */
   for each abss_det where
            abss_abs_id     = abs_id    and
            abss_shipfrom   = abs_shipfrom
   no-lock:

      run delete_abss_det
         (input recid(abss_det)).

   end.
end.  /* DELETE ALL */

/* --- INTERNAL PROCEDURES --- */

PROCEDURE delete_abss_det:
/*--------------------------------------------------------------------
  Purpose:
  Parameters:
  Notes:
---------------------------------------------------------------------*/
   define input parameter in_abss_recid as recid no-undo.

   for first abss_det
   where recid (abss_det) = in_abss_recid
   exclusive-lock:

      run delete_x_ref
         (input recid(abss_det)).

      for first rcsd_det where
            rcsd_shipfrom   = abss_shipfrom and
            rcsd_shipto     = abss_shipto   and
            rcsd_rlse_id    = abss_rlse_id  and
            rcsd_cust_job   = abss_cust_job and
            rcsd_cust_seq   = abss_cust_seq and
            rcsd_part       = abss_part     and
            rcsd_date       = abss_date     and
            rcsd_time       = abss_time     and
            rcsd_cust_ref   = abss_cust_ref and
            rcsd_dock       = abss_dock     and
            rcsd_line_feed  = abss_line_feed:
      end.

      if available (rcsd_det) then
      assign
         rcsd_picked     = no
         rcsd_mod_userid = global_userid
         rcsd_mod_date   = today
         rcsd_mod_pgm    = program-name(2).

      delete abss_det.

   end.  /* for first abss_det where */

END PROCEDURE. /* delete_abss_det */

PROCEDURE delete_x_ref:
/*--------------------------------------------------------------------
  Purpose:
  Parameters:
  Notes:
---------------------------------------------------------------------*/
   define input parameter in_abss_recid as recid no-undo.

   define buffer rcsd_det_xref for rcsd_det.

   for first abss_det
   where recid(abss_det) = in_abss_recid
   exclusive-lock:

      do for rcsd_det_xref:

         for each rcsx_ref where
               rcsx_shipfrom           = abss_shipfrom and
               rcsx_shipto             = abss_shipto   and
               rcsx_shipped_rlse_id    = abss_rlse_id  and
               rcsx_shipped_cust_job   = abss_cust_job and
               rcsx_shipped_cust_seq   = abss_cust_seq and
               rcsx_shipped_part       = abss_part     and
               rcsx_shipped_date       = abss_date     and
               rcsx_shipped_time       = abss_time     and
               rcsx_shipped_cust_ref   = abss_cust_ref and
               rcsx_shipped_dock       = abss_dock     and
               rcsx_shipped_line_feed  = abss_line_feed
               exclusive-lock:

            for each rcsd_det_xref where
                  rcsd_shipfrom   = rcsx_shipfrom and
                  rcsd_shipto     = rcsx_shipto   and
                  rcsd_rlse_id    = rcsx_rlse_id  and
                  rcsd_cust_job   = rcsx_cust_job and
                  rcsd_cust_seq   = rcsx_cust_seq and
                  rcsd_part       = rcsx_part     and
                  rcsd_date       = rcsx_date     and
                  rcsd_time       = rcsx_time     and
                  rcsd_cust_ref   = rcsx_cust_ref and
                  rcsd_dock       = rcsx_dock     and
                  rcsd_line_feed  = rcsx_line_feed:

               assign
                  rcsd_x_referenced   = no
                  rcsd_mod_userid = global_userid
                  rcsd_mod_date   = today
                  rcsd_mod_pgm    = program-name(3).

            end.  /* for each rcsd_det_xref */

            delete rcsx_ref.

         end.  /* for each rcsx_ref */

      end.  /* do for rcsd_det_xref */

   end.  /* for first abss_det  */

END PROCEDURE. /* delete_x_ref */
